<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="author" content="wangbo">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>from组件</title>
</head>

<body>
    <div id="app" >

    </div>
    <!-- 开发库 -->
    <script src="../js/react.development.js"></script>
    <!-- react 操作dom的库 -->
    <script src="../js/react-dom.development.js"></script>
    <!-- 设置组件props的库 -->
    <script src="../js/prop-types.js"></script>
    <!-- 解析jsx语法的 -->
    <script src="../js/babel.min.js"></script>
    <script type="text/babel">
    // 学习组件如何收集信息
        class Myform extends React.Component {
            state={  myinpt:"123" ,gd:1 }
            chg = (event) => {}
            chgr = (event)=>{ 
                if (event.target.value=='男') {
                    // setState 传入哪个值,回去改哪个值
                    // checked={this.state.gd==1} 默认勾选项 
                    this.setState({gd:2               })      
                }else{
                    this.setState({gd:1               })      
                }
                         
            }
            render() {
                return (
                    <form action="" method="get">
                        用户名<input type="text" ref={e=>this.mye = e} /> <br/>
                        密码 <input type="text" value={this.state.myinpt} onChange={this.chg}  /> <br/>
                        性别
                        <input type="radio" name="gender" id="" value='男'  checked={this.state.gd==2} onChange={this.chgr} />
                        <input type="radio" name="gender" id="" value='女' checked={this.state.gd==1}  onChange={this.chgr}/> <br/>
                        <input type="submit" value="提交" />
                    </form>
                )
            }
        }
        ReactDOM.render(<Myform />, document.getElementById('app'))
    </script>



</body>

</html>